package com.sky.controller.ai;

import com.sky.context.BaseContext;
import com.sky.dto.UserDTO;
import com.sky.result.Result;
import com.sky.service.AiChatService;
import com.sky.service.UserService;
import com.sky.vo.UserVO;
import lombok.AllArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@AllArgsConstructor
@RequestMapping("/ai")
@Slf4j
public class AiController {

    private final UserService userService;

    private final AiChatService aiChatService;





    @RequestMapping(value = "/chat",produces = "text/html;charset=utf-8")
    public String chat(@RequestParam String message) {
        long id = BaseContext.getCurrentId();
        return aiChatService.chat(id, message);
    }


    @PostMapping("/login")
    public Result<UserVO> login(@RequestBody UserDTO userDTO) {
        log.info("登录参数：{}", userDTO.getNickname());
        UserVO userVO = userService.login(userDTO);
        return Result.success(userVO);
    }
}
